package com.woniu113.junk.order.util;

import com.alipay.api.AlipayClient;
import com.alipay.api.AlipayConfig;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@Data
public class AlipayConfiguration {
    private String serverUrl;
    private String appid;
    private String privateKey;
    private String alipayPublicKey;
    @Bean
    public AlipayClient config() throws Exception {
        AlipayConfig alipayConfig = new AlipayConfig();
        //设置网关地址
        alipayConfig.setServerUrl("https://openapi-sandbox.dl.alipaydev.com/gateway.do");
        //设置应用ID
        alipayConfig.setAppId("9021000140632795");
        //设置应用私钥
        alipayConfig.setPrivateKey("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDEDPWi1OAgAsm5htWVYDg+DkqneABrnwVtGcicR/Prp7NKEPAy69Bf+Tv7/Kd+yEHPHYWvbAaJoXSnjfHmx8qqXWaqcp7QSC0KlTFfXj146hEp4aTbAxB6JmfeLmt4Sdc6pLmO4EjM6qAB6ngfvn1qzIUUAnqOc24BLVRnjeJx6cReJr9j1iRbZMc1Hs955iHKigEeD6Who1zUWM68Q2nL8A/i32DS991/VfbdzEgEFaVzm23ZyF5XMlV0RiVCYZ28zFcZ5oUpmuksV/Aw522wbHH0DMK9YD/F3OfMfVc3GBfWJHIMKevup2vqKB5QxJBCzEU4yUnt/MjY+u2GIxSlAgMBAAECggEACPoy8U7gKHcYN6el9h4e1TCgWITVOBhjDjjlB8r/r2XRfu3BogNMWmi2R3atUM/ou4w1h+/haMH87oNAdXnmnOCECAARp6X2cgqc5SoSlIvbV1iezOyZ/43sqa7kevCeq2/Jk3JPwxpnU08iSwnVAmP1IBJw/D7q5aDmwYssuFyQfKNmY++jyUGLIMhQd73ecsqL4fJtZb3qE0JN1+h2+35UqlMkMc+MH0/7TeKUwTHI0rpBiWV/xEtXSbYirFZ3RiKU9mNvWoMILeE2eoQMU46KT9XStJwzeTXX/WANZquXtxObm9s4Bxh5YNgJtnn6uERop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sIbO4tclMVqChZAikcMKvUWPzUKFmn7AwBxw1fJZjTLtYBssI9eSfFGTDI0XUnu5MxzUtVHb2Vd3/3NhGKKzhkjdoNuFPGwAI6Wyoswe1KPnWK/np4HkMPOJoXCpZCAfl3wsQLvBpwMDiLdbaca4rUcTnPQYggqcC1VO5IJxIqL+dTLTEqcrAH+d+IBzLXHO/JIy7SpTiOqBZxfOkm58YRw1E1TVrlvwYZ5U1difjjY5ewIDAQAB");
        //设置请求格式固定值json
        alipayConfig.setFormat("JSON");
        //设置字符集
        alipayConfig.setCharset("UTF-8");
        //设置签名类型
        alipayConfig.setSignType("RSA2");
        //实例化客户端
        AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig);
        return alipayClient;
    }
}